import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import local_get from '@dfeidao/atom-mobile/local/get';
import local_set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
import render from '@dfeidao/atom-mobile/render/render';

export default async function a005(fd: IFeidaoAiMobile, e: Event, args: { page_no: number }) {

	const page_no = args.page_no;
	const teacher_no = await local_get(fd, 'teacher_no');
	const productid = await local_get(fd, 'productid');
	const task_data: [] = await local_get(fd, 'task_data');

	const new_task_data = await nodejs<Array<{}>>('app-arrange-homework/s001', { filter: { teacher_no }, productid, page_no });
	// 避免使用concat连接数据,否则会使页面数据排序不停地变动
	const arr = [...task_data, ...new_task_data];
	await local_set(fd, 'task_data', arr);

	render(fd, { dt: arr, page_no, new_len: new_task_data.length });

}
